﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SIGCBI.Entities;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace SIGCBI.Repository.Mapping
{
    public class ClienteMap : EntityTypeConfiguration<CLIENTE>
    {
        public ClienteMap() 
        {
            //key
            this.HasKey(o => o.ID);

            //propiedades
            this.Property(o => o.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(o => o.Nombre).IsRequired();
            this.Property(o => o.Direccion);
            this.Property(o => o.Telefono);

            //table
            this.ToTable("CLIENTE");

            this.HasMany(e => e.ALQUILERs)
                .WithRequired()
                .HasForeignKey(p => p.IdCliente)
                .WillCascadeOnDelete(false);

        }
    }
}
